﻿/*=========================================================================
 * AUTH: Vincent Breton
 * DESC: Display Credits
 * REF: Stellar Siege Project 2010
 *=========================================================================*/
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace RisingThreat
{

    class CreditScreen:MenuScreen
    {
        SpriteFont font;
        int width;
        int height;
        Texture2D black;
        Rectangle blackRect1, blackRect2, srcRect;
        TextScroller scroller;
        String creditText;
        Vector2 creditMenuPos;

        public CreditScreen(ContentManager content, EventHandler gameEvent, GraphicsDeviceManager graphics)
            : base(content, gameEvent, graphics)
        {
            String[] optionsList = new String[]{"Back to Main Menu"};
            base.setOptions(optionsList);

            font = content.Load<SpriteFont>("fonts/Cutscene");
            width = graphics.PreferredBackBufferWidth;
            height = graphics.PreferredBackBufferHeight;

            black = content.Load<Texture2D>("textures/blank");
            blackRect1 = new Rectangle(0, 0, width, (int)(titleFont.MeasureString(base.title).Y+base.titlePos.Y));//+80));
            creditMenuPos = new Vector2(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.TitleSafeArea.X + GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.TitleSafeArea.Width / 2 - ((menuFont.MeasureString(options[0]).X) / 2), GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.TitleSafeArea.Y + GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.TitleSafeArea.Height - menuFont.MeasureString(options[0]).Y - 15);
            blackRect2 = new Rectangle(0, (int) creditMenuPos.Y - 15, width, (int) creditMenuPos.Y + 15);
            srcRect = new Rectangle(0, 1, 1, 1);

            creditText = " Concordia University\n\n" +

                "A COMP 476 Group Project\n" +
                "\"Rising Threat\"\n\n" +
                "Developed by:\n" +
                "Marc LeDuc\n" +
                "Matthew Baum\n" +
                "Vincent Breton\n";
               

            scroller = new TextScroller(creditText, font, new Vector2(0, -0.35f), new Vector2(width/2,height-150), 16);

        }


        public override void Update(GameTime gametime)
        {
            base.Update(gametime);

            scroller.Update((float)gametime.ElapsedGameTime.TotalMilliseconds);
            if (scroller.TextBottom < blackRect1.Bottom)
            {
                screenEvent.Invoke(this, new EventArgs());
            }
        }

        public override void Draw(SpriteBatch batch)
        {
            //Draw Credit
            scroller.Draw(batch);
            batch.Draw(black, blackRect1, srcRect, Color.Black, 0, Vector2.Zero, SpriteEffects.None, 0.5f);
            batch.Draw(black, blackRect2, srcRect, Color.Black, 0, Vector2.Zero, SpriteEffects.None, 0.5f);

            //Draw Title
            batch.DrawString(titleFont, title, titlePos, Color.White);
            //Draw Menu

            batch.DrawString(menuFont, options[0],creditMenuPos, Color.Yellow);

            
        }
    }
}
